home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Varsity Update 1998 August
/
SGI Varsity Update 1998 August.iso
/
docs6.4
/
relnotes
/
c_fe
/
ch4.z
/
ch4
Wrap
Text File
|
1998-07-29
|
25KB
|
858 lines
- 1 -
7.2.1 ANSI C Front-End Release Notes
- 2 -
DDDDooooccccuuuummmmeeeennnntttt NNNNuuuummmmbbbbeeeerrrr 000000007777----1111666655559999----000011110000
4. _N_e_w__F_e_a_t_u_r_e_s__o_f__T_h_i_s__R_e_l_e_a_s_e
This chapter contains the differences between
this release and the 7.2 release of the MIPSpro
C compiler. It also summarizes the differences
between the 7.2 release and the 7.1 release of
MIPSpro C compiler.
4.1 _N_e_w__F_e_a_t_u_r_e_s__i_n__M_I_P_S_p_r_o__7_._2_._1
4.1.1 _I_n_l_i_n_e__M_e_m_o_r_y__I_n_t_r_i_n_s_i_c_s The following
new options which control the inlining of memory
intrinsics
have been added to the -_O_P_T option group:
- 3 -
-OPT:....
mem_intrinsics[=(OFF|ON)]
Enable inlining of memory intrinsics
(memcpy, memmove, memset, bcopy, bzero,
blkclr) in some cases. This option has
an effect only if the corresponding
procedure has a "#pragma intrinsic"
for it. The standard include files
contain this pragma for these routines
(string.h, memory.h, bstring.h, strings.h).
Note that the pragmas are disabled by
default with the -ansi option. The option
-D__INLINE_INTRINSICS can be used to
enable intrinsics in the -ansi mode.
(default OFF)
memcpy_cannot_overlap[(OFF|ON)]
The compiler assumes by default that
the operands of the "memcpy" routine
can overlap. This option allows the
compiler to assume that the operands do
not overlap and can thus generate
better code. (default OFF)
bcopy_cannot_overlap[(OFF|ON)]
The compiler assumes by default that
the operands of the "bcopy" routine
can overlap. This option allows the
compiler to assume that the operands
do not overlap and can thus generate
better code. (default OFF)
memmove_cannot_overlap[(OFF|ON)]
The compiler assumes by default that the
operands of the "memmove" routine can
overlap. This option allows the compiler
to assume that the operands do not overlap
and can thus generate better code.
(default OFF)
memmove_count=n
Specify the maximum number of instructions
that will be generated in the inline
expansion for the memory intrinsics.
(default 16)
- 4 -
4.2 _N_e_w__B_o_o_k_s
The _M_I_P_S_P_r_o _C _a_n_d _C++ _P_r_a_g_m_a_s is now available
as an online document in the subsystem
_c_o_m_p_i_l_e_r__d_e_v._b_o_o_k_s._P_r_a_g_m_a_s. This revision of
the manual, however, omits several pragmas that
are supported:
4.2.1 _#_p_r_a_g_m_a__c_o_n_c_u_r_r_e_n_t #pragma concurrent
instructs the compiler, when analyzing the loop
immediately following this assertion, to ignore
all dependences between two references to the
same array.
4.2.1.1 _U_s_i_n_g__#_p_r_a_g_m_a__c_o_n_c_u_r_r_e_n_t The syntax
of #pragma concurrent is as follows:
#pragma concurrent
There are five facts to be aware of when using
this pragma:
+o If multiple loops in a nest can be
parallelized, #pragma concurrent causes the
compiler to prefer the loop immediately
following the pragma.
+o Applying this pragma to an inner loop may
cause the loop to be made outermost by the
compiler's loop interchange operations.
+o #pragma concurrent does not affect how the
compiler analyzes function calls.
+o #pragma concurrent does not affect how the
compiler analyzes dependences between two
potentially aliased pointers.
+o If there are real dependences between array
references, #pragma concurrent may cause
the compiler to generate incorrect code.
- 5 -
4.2.2 _#_p_r_a_g_m_a__c_o_n_c_u_r_r_e_n_t__c_a_l_l The #pragma
concurrent call directive instructs the compiler
to ignore the dependences of subroutine and
function calls contained in the loop that
follows the directive.
4.2.2.1 _U_s_i_n_g__#_p_r_a_g_m_a__c_o_n_c_u_r_r_e_n_t__c_a_l_l The
syntax for #pragma concurrent call is as
follows:
#pragma concurrent call
The pragma applies to the loop that immediately
follows it and to all loops nested inside that
loop. To prevent incorrect parallelization,
make sure the following conditions are met:
+o A function inside the loop cannot read from
a location that is written to during
another iteration. This rule does not apply
to a location that is a local variable
declared inside the function.
+o A function inside the loop cannot write to
a location that is read from or written to
during another iteration. This rule does
not apply to a location that is a local
variable declared inside the function.
4.2.2.2 _E_x_a_m_p_l_e_s__o_f__#_p_r_a_g_m_a__c_o_n_c_u_r_r_e_n_t__c_a_l_l
- 6 -
Example 1
In this example the compiler ignores the dependences in the function
fred() when it analyzes the following loop:
#pragma concurrent call
for (i = 0; i < N; i++0
{
fred(...)
...
}
void fred (...)
{
...
}
Example 2
The following code shows an illegal use of the assertion.
Function fred() writes to variable T, which is also read
from by wilma() during other iterations.
float A[M], B[M];
int i, T;
#pragma concurrent call
for (i = 0; i < M; i++)
{
fred(B, i, &T);
wilma(A, i, &T);
}
void fred(float B[], int i, int* T)
{
*T = B[i];
}
void wilma(float A[], int i, int* T)
{
A[i] = *T;
}
By localizing the variable T, you can manually parallelize
the above example safely. But the compiler does not know to
localize T, and it illegally parallelizes the loop because of
the assertion.
- 7 -
4.2.3 _#_p_r_a_g_m_a__p_e_r_m_u_t_a_t_i_o_n When placed inside
a subroutine, #pragma permutation tells the
compiler that the specified array is a
permutation array.
4.2.3.1 _U_s_i_n_g__#_p_r_a_g_m_a__p_e_r_m_u_t_a_t_i_o_n The syntax
of #pragma permutation is as follows:
#pragma permutation (array)
The variable array is the name of a permutation
array. Every element of array has a distinct
value. The directive does not require the
permutation array to be dense. In other words,
while every array[1] must have a distinct value,
there can be gaps between those values, such as
array[1] = 1, array[2] = 4, array[3] = 9, and so
on.
You can use this assertion to parallelize loops
that use arrays for indirect addressing. Without
this directive, the compiler cannot determine
that the array elements used as indexes are
distinct.
This pragma affects every loop in a subroutine,
even those that appear ahead of it.
4.3 _N_e_w__F_e_a_t_u_r_e_s__i_n__M_I_P_S_p_r_o__7_._2
4.3.1 _R_e_p_a_c_k_a_g_i_n_g__o_f__F_r_o_n_t_-_E_n_d__S_u_b_s_y_s_t_e_m_s
Starting with the 7.2 release, the C compiler
front-end is packaged in its own subsystem on a
separate CD. For proper installation, you must
install _c_o_m_p_i_l_e_r__d_e_v, _c_o_m_p_i_l_e_r__e_o_e and _c__d_e_v
from the IRIX Development Foundation CD as well
as _c__f_e from the MIPSpro C Compiler CD.
4.3.2 _N_e_w__O_p_t_i_o_n_s__a_n_d__D_e_f_a_u_l_t_s A new
-_D_E_B_U_G:_o_p_t_i_o_n control group has been created to
allow insertion of code to assist in the
debugging of programs. For example,
- 8 -
-_D_E_B_U_G:_d_i_v__c_h_e_c_k=_N replaces -_T_E_N_V:_c_h_e_c_k__d_i_v=_N
and the 7.2 compiler, by default, inserts code
to check for divide by zero (N=1).
_N_O_T_E: The default value for -_T_E_N_V:_c_h_e_c_k__d_i_v=_N
under MIPSpro 7.1 was N=0 (no checks).
For more information, please refer to the _c_c(1)
and _D_E_B_U_G__g_r_o_u_p(5) man pages.
The -_L_I_S_T: options control group has been
enhanced to the create a listing file (.l) that
contains the values of all flags modified,
directly in the command line, or indirectly as a
side effect of other options. For example:
% cc -n32 -LIST:options=ON foo.c
will create foo.l which contains a listing that
contains the default values of certain options
from the -OPT, -LNO, -TARG and -TENV option
control groups.
The following command:
% cc -n32 -LIST:all_options=ON foo.c
will create foo.l which contains a listing that
contains the default values of all options from
all of the option control groups.
For more information, please refer to the _c_c(1)
man page.
4.3.3 _O_b_s_o_l_e_t_e__O_p_t_i_o_n_s Several compile-time
flags have been obsoleted. These include:
-_T_E_N_V:_m_i_s_a_l_i_g_n_e_m_n_t=_N, -_T_E_N_V:_a_l_i_g_n__e_x_t_e_r_n=_N and
-_T_E_N_V:_a_l_i_g_n_e_d=_T_R_U_E. Their use will generate a
warning message in both the compiler front-end
and backend. For example:
% cc -n32 -TENV:misalignment=3 reshape.c
Warning: Obsolete option "-TENV:misalignment=3" -- ignored
Warning: Obsolete option "-TENV:misalignment=3" -- ignored
The -_T_E_N_V:_v_a_r_a_r_g_s__p_r_o_t_o_t_y_p_e_s=_T_R_U_E flag has been
replaced by -_D_E_B_U_G:_v_a_r_a_r_g_s__p_r_o_t_o_t_y_p_e_s=_T_R_U_E.
For more information, please refer to the _c_c(1)
and _D_E_B_U_G__g_r_o_u_p(5) man pages.
- 9 -
4.3.4 _V_a_r_i_a_b_l_e__L_e_n_g_t_h__A_r_r_a_y_s MIPSpro 7.2 now
supports variable length arrays. Array dummy
arguments and local arrays can now be declared
as variable length arrays rather than as
pointers. This allows the compiler to make
assumptions about aliasing and can allow more
optimizations to be applied to code containing
references to the array. This is particularly
beneficial for parallelization. The syntax for
variable length arrays is:
int foo( int n, float a[n][n] ) {
float b[n]
}
In the example above, dummy argument a and local
variable b are both variable length arrays.
4.3.5 _F_r_e_q_u_e_n_c_y__h_i_n_t__p_r_a_g_m_a_s MIPSpro 7.2 now
supports a new pragma "#pragma
mips_freqency_hint" that is used to tell the
compiler that a branch or function is rarely or
frequently executed. The compiler uses this
information to make better optimization
decisions. A branch can be marked as infreqently
taken in this fashion:
if ( a < b ) {
#pragma mips_frequency_hint NEVER
printf("error condition0);
}
While a function can be so marked this way:
void handle_error( int i );
#pragma mips_frequency_hint NEVER handle_error
To specify that a block of code gets frequently
executed, you can use:
#pragma mips_frequency_hint FREQUENT
Frequency information about a function gets
propogated to all instances where the function
- 10 -
is used. So a branch that contains a call to an
infrequent function is considered infrequently
executed itself.
4.3.6 _F_i_l_l__a_n_d__A_l_i_g_n__P_r_a_g_m_a__S_u_p_p_o_r_t MIPSpro
7.2 C supports new types of pragmas to
facilitate padding and alignment of variables
within cachelines and pages of memory. They are
outlined below.
#pragma fill_symbol (s, L1cacheline)
#pragma fill_symbol (s, L2cacheline)
#pragma fill_symbol (s, page)
#pragma fill_symbol (s, <user-specified-power-of-two>)
#pragma align_symbol (s, L1cacheline)
#pragma align_symbol (s, L2cacheline)
#pragma align_symbol (s, page)
#pragma align_symbol (s, <user-specified-power-of-two>)
The fill_symbol and align_symbol pragmas take a
symbol (i.e. a variable that may be a C global,
an automatic variable, but not a formal and not
an element of a structured type like a struct or
an array). The second argument in the pragma
may be one of the keywords L1cacheline (machine
specific first-level cache line size, typically
32 bytes), L2cacheline (machine specific
second-level cache line size, typically 128
bytes), page (machine specific page size,
typically 16 Kbytes), or a user-specified
power-of-two value.
The align_symbol pragma aligns the start of the
named symbol at the specified alignment, i.e.
the symbol "s" will start at the specified
alignment boundary.
The fill_symbol pragma pads the named symbol
with additional storage so that the symbol is
assured not to overlap with any other data item
within the storage of the specified size. The
additional padding required is heuristically
divided between each end of the specified
variable. For instance, a fill_symbol pragma for
the L1cacheline will guarantee that the
specified symbol will not suffer from false-
sharing for the L1 cache line.
- 11 -
For global variables these pragma must be
specified at the variable definition, and are
optional at the declarations of the variable.
The align_symbol pragma is ineffective for local
variables of fixed-size symbols, such as simple
scalars or arrays of known size. The pragma
continues to be effective for stack-allocated
arrays of dynamically-determined size.
A variable cannot have both fill_symbol and
align_symbol pragma applied to it.
4.3.7 _E_n_h_a_n_c_e_m_e_n_t_s__f_o_r__M_u_l_t_i_p_r_o_c_e_s_s_i_n_g
Several new enhancements related to
multiprocessing have been made to MIPSpro C 7.2:
4.3.7.1 _D_a_t_a__D_i_s_t_r_i_b_u_t_i_o_n__P_r_a_g_m_a_s MIPSpro 7.2
C now supports pragmas for page-level data
distribution and dynamic redistribution. These
include _p_a_g_e__p_l_a_c_e, _d_i_s_t_r_i_b_u_t_e, _d_i_s_t_r_i_b_u_t_e
_r_e_s_h_a_p_e, _d_y_n_a_m_i_c, _r_e_d_i_s_t_r_i_b_u_t_e.
4.3.7.2 _O_t_h_e_r__N_e_w__M_P__P_r_a_g_m_a_s The following
list of pragmas are new for 7.2 and related to
multiprocessing: _c_o_n_c_u_r_r_e_n_t, _s_e_r_i_a_l, _c_o_n_c_u_r_r_e_n_t
_c_a_l_l, _c_o_n_c_u_r_e_n_t_i_z_e, _n_o_c_o_n_c_u_r_r_e_n_t_i_z_e, _p_r_e_f_e_r
_s_e_r_i_a_l, _p_r_e_f_e_r _c_o_n_c_u_r_r_e_n_t, _p_e_r_m_u_t_a_t_i_o_n.
The full set of pragmas supported by C are
described in the new _M_I_P_S_p_r_o _C _a_n_d _C++ _P_r_a_g_m_a_s
manual.
4.3.7.3 _M_P___S_L_A_V_E___S_T_A_C_K_S_I_Z_E The stacksize of
slave processes can be controlled through the
environment variable MP_SLAVE_STACKSIZE, which
may be set to the desired stacksize in bytes.
The default value is 16 Mbytes (4 MB for greater
than 64 threads).
4.3.8 _S_t_r_i_c_t_e_r__E_r_r_o_r__M_e_s_s_a_g_e The example
below would incorretly compile with MIPSpro 7.1
without any errors. The MIPSpro 7.2 compilers
- 12 -
will emit an error:
Example:
%cat a.c
struct st1_t;
struct st2_t {
struct st1_t st1;
};
struct st2_t st2;
main()
{
}
%cc -n32 -c a.c
"a.c", line 3: error(1070): incomplete type is not allowed
struct st1_t st1;
^
1 error detected in the compilation of "a.c".
The fix is to declare a complete type before its
use.
4.3.9 _S_t_r_i_c_t_e_r__W_a_r_n_i_n_g__M_e_s_s_a_g_e The C compiler
now checks the arguments with the corresponding
conversion specification in the format strings
of calls to printf(), sprintf(), fprintf(),
scanf(), fscanf, and sscanf(). This can result
in the following warning:
warning/error(1178): argument is incompatible with corresponding
format string conversion
This is normally a warning. However, it will be
reported as an error if the -_d_i_a_g__e_r_r_o_r option
is used. The fix is to use the correct
conversion character for the type of the
argument.
4.3.10 _P_R_I_N_T_F_L_I_K_E___l_i_n_t___s_t_y_l_e___c_o_m_m_e_n_t These
are lint comments for checking validity of
arguments They applies lint style check to the
first (n-1) arguments as usual. The nth argument
is interpreted as a printf format string that is
used to check the remaining arguments.
- 13 -
4.3.11 _S_C_A_N_F_L_I_K_E___l_i_n_t___s_t_y_l_e___c_o_m_m_e_n_t This
comment applies lint style check to the first
(n-1) arguments as usual. The nth argument is
interpreted as a scanf format string that is
used to check the remaining arguments.